Coding Interview Ninja: 50 coding questions with Java solutions to practice for your coding interview. by Ekim Ouye
Author:Ekim Ouye [Ouye, Ekim]
Language: eng
Format: epub
Tags: Computers & Technology
Published: 2015-03-28T07:00:00+00:00
AVERAGE RUNNING TIME COMPLEXITY:
O(N)
WORST RUNNING TIME COMPLEXITY:
O(N2)
SPACE COMPLEXITY:
O(1)
22.Given that a tree is a full binary tree (= every node other than the leaves has two children) and the pre-order and post-order traversal of the tree, re-construct it.
e.g:
input:
pre-order: 5, 3, 7
post-order: 3, 7, 5
output:
tree:
5
3 7
_______________
SOLUTION:
static int mPreIndex = 0;
public static TNode constructTree(int[] pre, int[] post, int lo, int hi) {
if ((lo > hi) || (mPreIndex >= pre.length)) {
return null;
}
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Motivation Myth by Jeff Haden(5177)
Audition by Ryu Murakami(4893)
Adulting by Kelly Williams Brown(4537)
The Confidence Code by Katty Kay(4223)
A Mind For Numbers: How to Excel at Math and Science (Even If You Flunked Algebra) by Barbara Oakley(3265)
Waiting in the Wings by Melissa Brayden(3198)
Self-Esteem by Matthew McKay & Patrick Fanning(3118)
Fooled by Randomness: The Hidden Role of Chance in Life and in the Markets by Nassim Nicholas Taleb(3083)
The ONE Thing by Gary Keller(3036)
Nice Girls Don't Get the Corner Office by Lois P. Frankel(3026)
The Dictionary of Body Language by Joe Navarro(2972)
How to be More Interesting by Edward De Bono(2770)
Designing Your Life by Bill Burnett(2706)
Getting Things Done by David Allen(2672)
The Plant Paradox by Dr. Steven R. Gundry M.D(2584)
Police Exams Prep 2018-2019 by Kaplan Test Prep(2518)
What Color Is Your Parachute? 2015 by Richard N. Bolles(2287)
Dangerous Personalities by Joe Navarro(2262)
When to Jump by Mike Lewis(2227)